/** 
 * TextStyles.java
 * @author Lex
 * 2007-9-12 ����12:31:59
 */
package org.lex.net.log.ui;

import javax.swing.text.AttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;

import org.lex.net.log.Log.Type;


public class TextStyles {
	private static AttributeSet[] styles = null;
	static {
		loadStyles();
	}

	public static AttributeSet getStyle(Type type) {
		return styles[type.ordinal()];
	}

	private static void loadStyles() {
		Type[] all = Type.values();
		styles = new AttributeSet[all.length];
		for (int i = 0; i < all.length; i++)
			styles[all[i].ordinal()] = getByLogType(all[i]);
	}

	private static AttributeSet getByLogType(Type type) {
		SimpleAttributeSet a = new SimpleAttributeSet();
		StyleConstants.setForeground(a, ColorConstants.getForeground(type));
		return a;
	}
}
